<link  href="admin/css/jsDatePick_ltr.min.css" rel="stylesheet" type="text/css" media="all" />
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="admin/css/jsDatePick.min.1.3.js"></script>
<script type="text/javascript" src="js/jquery.price_format.1.7.js"></script>
<script type="text/javascript" src="js/jquery.price_format.1.7.min.js"></script>
<?php
session_cache_expire(999999999);
 if(!isset($_SESSION)) 
{ 
session_start(); 
} 
	

	if (isset($_SESSION['successus'])){
		echo "<script>alert('$l_themthanhcong');</script>";
		unset($_SESSION['successus']);
	}

	if (isset($_SESSION['successup'])){
		echo "<script>alert('$l_capnhatthanhcong');</script>";
		unset($_SESSION['successup']);
	}

	if (isset($_SESSION['successdel'])){
		echo "<script>alert('$l_xoathanhcong');</script>";
		unset($_SESSION['successdel']);
	}
	
	if (isset($_SESSION['listreference1'])){
		unset($_SESSION['listreference1']);
		unset($_SESSION['namereference1']);
		unset($_SESSION['slreference1']);
	}
if(!isset($_REQUEST["abc"])){
	$_REQUEST["abc"]="all";
}
$_SESSION['loaitimkiem']=$_REQUEST["abc"];
if($_SESSION['loaitimkiem']=="ngay"){
	$_REQUEST['datefrom']=date("Y-m-d");
	$_REQUEST['dateto']=date("Y-m-d");
	$_REQUEST['vttime']=$_REQUEST['datefrom']." ~ ".$_REQUEST['dateto'];
}else if($_SESSION['loaitimkiem']=="thang"){
	$_REQUEST['syear']=$vyear=date("Y");
	$_REQUEST['smonths']=date("m");
	$ntt=date("t",mktime(0,0,0,$_REQUEST['smonths'],1,$_REQUEST['syear']));
	if($_REQUEST['smonths']<10){
		$_REQUEST['vttime']=$_REQUEST['syear']."-0".$_REQUEST['smonths']."-01"." ~ ".$_REQUEST['syear']."-0".$_REQUEST['smonths']."-".$ntt;
	}else{
		$_REQUEST['vttime']=$_REQUEST['syear']."-".$_REQUEST['smonths']."-01"." ~ ".$_REQUEST['syear']."-".$_REQUEST['smonths']."-".$ntt;
	}
}else if($_SESSION['loaitimkiem']=="qui"){
	$_REQUEST['nam']=$vyear=date("Y");
	$_REQUEST['qmonths']=$mangquy[date("m")-1];
	$ntt=date("t",mktime(0,0,0,$mq[$_REQUEST['qmonths']][1],1,$_REQUEST['nam']));
	if($mq[$_REQUEST['qmonths']][0]<10){
		$_REQUEST['vttime']=$_REQUEST['nam']."-0".$mq[$_REQUEST['qmonths']][0]."-01"." ~ ".$_REQUEST['nam']."-0".$mq[$_REQUEST['qmonths']][1]."-".$ntt;
	}else{
		$_REQUEST['vttime']=$_REQUEST['nam']."-".$mq[$_REQUEST['qmonths']][0]."-01"." ~ ".$_REQUEST['nam']."-".$mq[$_REQUEST['qmonths']][1]."-".$ntt;
	}
	
}
else if($_SESSION['loaitimkiem']=="all"){
	$_REQUEST['nam']=$vyear=date("Y");
	if(isset($_REQUEST['nam']))
		$_REQUEST['vttime']=$_REQUEST['nam']."-01-01"." ~ ".$_REQUEST['nam']."-12-31";
	else $_REQUEST['vttime']='~';
	
}

$sql="SELECT c.*,t.name$lang,e.FullName FROM contract c,contract_type t,employee e WHERE c.type=t.id AND c.signer=e.IDEmployee AND c.status=0 ";
	if(isset($_SESSION['sqlcontract']))
		unset($_SESSION['sqlcontract']);
	$_SESSION['sqlcontract']=$sql;	
	$_SESSION['ASC_DESC']='DESC';	
	$sql.="order by c.signDay ".$_SESSION['ASC_DESC'];

$sqlempworking = mysql_query($sql);
$soluong=mysql_num_rows($sqlempworking);
$mangContractType=mysql_query("SELECT * FROM contract_type;");

$addressbrowser = $_SERVER['SERVER_NAME'];
$temp = explode(".", $addressbrowser);
$queryDepartment = mysql_query("SELECT d.IDDepartment,dl.DepartmentName FROM department d,department_lang dl WHERE d.IDDepartment=dl.IDDepartment AND dl.LangID='$lang';");
$querySendMail = mysql_query("SELECT e.IDEmployee,e.FullName FROM list_sendmail l,employee e WHERE l.employee_id=".$_SESSION['IDEmployee']." AND e.IDEmployee=l.employee_id_sendmail GROUP BY l.employee_id_sendmail");
include 'popup/popup_reference2.php';
?>

<script type="text/javascript">
	
$(document).ready(function(){
	$("#nameCompany").autocomplete("operations/rpc_contract_company.php", {
		selectFirst: true
		
	});
	$('#content_menu_expand').hide();
	$(document).click(function() {
		$("#content_menu_expand").hide();
	});
	$('#content_menu_expand').click(function(e) {
		e.stopPropagation();
	});

	$('#menu_expand').click(function() {
		if ($('#content_menu_expand').is(":hidden")) {
			var gt=document.getElementById("checkkhung").checked;
			if(gt==false){
				$('#content_menu_expand').show();
			}
		}
		else {
			$('#content_menu_expand').hide();
		}
		return false;
	});


	$("#nameProduct").autocomplete("operations/rpc_contract_nameProduct.php", {
		selectFirst: true
		
	});
	
	$('#content_menu_expand6').hide();
	$(document).click(function() {
		$("#content_menu_expand6").hide();
	});
	$('#content_menu_expand6').click(function(e) {
		e.stopPropagation();
	});

	$('#menu_expand6').click(function() {
		if ($('#content_menu_expand6').is(":hidden")) {
			var gt=document.getElementById("checkkhung6").checked;
			if(gt==false){
				$('#content_menu_expand6').show();
			}
		}
		else {
			$('#content_menu_expand6').hide();
		}
		return false;
	});
	
});
function Load(){
	$("#nameCompany").autocomplete("operations/rpc_contract_company.php", {
		selectFirst: true
		
	});
	$('#content_menu_expand').hide();
	$(document).click(function() {
		$("#content_menu_expand").hide();
	});
	$('#content_menu_expand').click(function(e) {
		e.stopPropagation();
	});

	$('#menu_expand').click(function() {
		if ($('#content_menu_expand').is(":hidden")) {
			var gt=document.getElementById("checkkhung").checked;
			if(gt==false){
				$('#content_menu_expand').show();
			}
		}
		else {
			$('#content_menu_expand').hide();
		}
		return false;
	});

	

	$("#nameProduct").autocomplete("operations/rpc_contract_nameProduct.php", {
		selectFirst: true
		
	});
	$('#content_menu_expand6').hide();
	$(document).click(function() {
		$("#content_menu_expand6").hide();
	});
	$('#content_menu_expand6').click(function(e) {
		e.stopPropagation();
	});

	$('#menu_expand6').click(function() {
		if ($('#content_menu_expand6').is(":hidden")) {
			var gt=document.getElementById("checkkhung6").checked;
			if(gt==false){
				$('#content_menu_expand6').show();
			}
		}
		else {
			$('#content_menu_expand6').hide();
		}
		return false;
	});


	
	
}
function dokhung(){
	var gt=document.getElementById("checkkhung").checked;
	if(gt==true){
		document.getElementById("nameCompany").value="";
		document.getElementById("nameCompany").style.backgroundColor ="#e9edf4";
		$("#nameCompany").attr('readonly', 'readonly');
	}else{
		document.getElementById("nameCompany").value="";
		document.getElementById('nameCompany').style.backgroundColor ="#ffffff";
		$("#nameCompany").removeAttr('readonly');
		document.getElementById('nameCompany').focus();
	}
}
function dokhung6(){
	var gt=document.getElementById("checkkhung6").checked;
	if(gt==true){
		document.getElementById("nameProduct").value="";
		document.getElementById("nameProduct").style.backgroundColor ="#e9edf4";
		$("#nameProduct").attr('readonly', 'readonly');
	}else{
		document.getElementById("nameProduct").value="";
		document.getElementById('nameProduct').style.backgroundColor ="#ffffff";
		$("#nameProduct").removeAttr('readonly');
		document.getElementById('nameProduct').focus();
	}
}
function clickCustomer(gt){
	document.getElementById("nameCompany").value=gt;
	$('#content_menu_expand').hide();
}
function clickCustomer6(gt){
	document.getElementById("nameProduct").value=gt;
	$('#content_menu_expand6').hide();
}
function donam(){
	var gt=document.getElementById("checknam").checked;
	if(gt==true){
		//document.getElementById("nam").value="";
		document.getElementById("nam").style.backgroundColor ="#e9edf4";
		$("#nam").attr('disabled', 'disabled');
		
	}else{
		//document.getElementById("nam").value="";
		document.getElementById('nam').style.backgroundColor ="#ffffff";
		$("#nam").removeAttr('disabled');
		document.getElementById('nam').focus();
		
	}

	changequi('tinhnam');
	
}
function changeDistinction(type){
	var typedate =$('input[name=ngaysearch]:checked').val();
	if(window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("idtab").innerHTML=xmlhttp.responseText;
										    	Load();
										    	if(type=='ngay'){
										    		new JsDatePick({
										    			useMode:2,
										    			target:"datefrom",
										    			dateFormat:"%Y-%m-%d"
										    		});
										    		new JsDatePick({
										    			useMode:2,
										    			target:"dateto",
										    			dateFormat:"%Y-%m-%d"
										    		});
										    	}
										  }
									  }
	xmlhttp.open("GET","content_contract/changeDistinction.php?abc="+type,true);
	xmlhttp.send();
	Load();
}
function changeyear(type){
	var eyear = document.getElementById("syear");
	var txtyear = eyear.options[eyear.selectedIndex].value;
	var emon = document.getElementById("smonths");
	var txtmon = emon.options[emon.selectedIndex].value;
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("showtime").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","content_contract/or_search_invoice_tax_time.php?type="+type+"&year="+txtyear+"&mon="+txtmon,true);
	xmlhttp.send();
}

function changequi(type){
	var eyear = document.getElementById("nam");	
	var txtyear = eyear.options[eyear.selectedIndex].value;
	if(type!="tinhnam"){
		var emon = document.getElementById("qmonths");
		var txtmon = emon.options[emon.selectedIndex].value;
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
											  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											    	document.getElementById("showtime").innerHTML=xmlhttp.responseText;
											  }
										  }
		  
		xmlhttp.open("GET","content_contract/or_search_invoice_tax_time.php?type="+type+"&year="+txtyear+"&qui="+txtmon,true);
		xmlhttp.send();
	}else{
		var gt=document.getElementById("checknam").checked;
		
		if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
			xmlhttp=new XMLHttpRequest();
		}else{// code for IE6, IE5
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
		xmlhttp.onreadystatechange=function(){
											  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											    	document.getElementById("showtime").innerHTML=xmlhttp.responseText;
											  }
										  }
		if(gt==false){
			xmlhttp.open("GET","content_contract/or_search_invoice_tax_time.php?type="+type+"&year="+txtyear,true);
		}else{
			xmlhttp.open("GET","content_contract/or_search_invoice_tax_time.php?type="+type,true);
		}
		xmlhttp.send();
	}
}

function viewclick(){
	//var txtloaitimkiem =$('input[name=abc]:checked').val();
	//alert(txtloaitimkiem);
	if(document.getElementById("abc_ngay").checked==true){
		txtloaitimkiem='ngay';
	}
	if(document.getElementById("abc_thang").checked==true){
		txtloaitimkiem='thang';
	}
	if(document.getElementById("abc_qui").checked==true){
		txtloaitimkiem='qui';
	}
	if(document.getElementById("abc_all").checked==true){
		txtloaitimkiem='all';
	}
	var body = document.getElementById('showview');
	body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
	
	var d=document.createElement('div');
	d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
	
	var image=document.createElement('img');
	image.setAttribute('src','images/loading1.gif');
	image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
	
	d.appendChild(image);
	
    body.appendChild(d);
	
	
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("showview").innerHTML=xmlhttp.responseText;
										    	document.getElementById('showview').setAttribute('style','opacity:1; position:relative;');
										    	Load();
										  }
									  }
	if(txtloaitimkiem=="all"){
		var cusname=document.getElementById("nameCompany").value;
		var nameProduct=document.getElementById("nameProduct").value;
		var type=document.getElementById("type").value;
		var statusPayment=document.getElementById("statusPayment").value;
		var nam=document.getElementById("nam").value;
		var gt=document.getElementById("checknam").checked;
		if(gt==true)
			xmlhttp.open("GET","content_contract/or_search_invoice_tax_month.php?loaitimkiem=all&cusname="+encodeURIComponent(cusname)+"&nameProduct="+encodeURIComponent(nameProduct)+"&type="+type+"&statusPayment="+statusPayment,true);
		else	
			xmlhttp.open("GET","content_contract/or_search_invoice_tax_month.php?loaitimkiem=all&cusname="+encodeURIComponent(cusname)+"&nam="+nam+"&nameProduct="+encodeURIComponent(nameProduct)+"&type="+type+"&statusPayment="+statusPayment,true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="ngay"){
		var cusname=document.getElementById("nameCompany").value;
		var df=document.getElementById("datefrom").value;
		var dt=document.getElementById("dateto").value;
		var nameProduct=document.getElementById("nameProduct").value;
		var type=document.getElementById("type").value;
		var statusPayment=document.getElementById("statusPayment").value;
		xmlhttp.open("GET","content_contract/or_search_invoice_tax.php?loaitimkiem=ngay&df="+df+"&dt="+dt+"&cusname="+encodeURIComponent(cusname)+"&nameProduct="+encodeURIComponent(nameProduct)+"&type="+type+"&statusPayment="+statusPayment,true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="thang"){
		var cusname=document.getElementById("nameCompany").value;
		var eyear = document.getElementById("syear");
		var txtyear = eyear.options[eyear.selectedIndex].value;
		var emon = document.getElementById("smonths");
		var txtmon = emon.options[emon.selectedIndex].value;
		var nameProduct=document.getElementById("nameProduct").value;
		var type=document.getElementById("type").value;
		var statusPayment=document.getElementById("statusPayment").value;
		xmlhttp.open("GET","content_contract/or_search_invoice_tax_month.php?loaitimkiem=thang&nam="+txtyear+"&thang="+txtmon+"&cusname="+encodeURIComponent(cusname)+"&nameProduct="+encodeURIComponent(nameProduct)+"&type="+type+"&statusPayment="+statusPayment,true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="qui"){
		var cusname=document.getElementById("nameCompany").value;
		var eyear = document.getElementById("nam");
		var txtyear = eyear.options[eyear.selectedIndex].value;
		var emon = document.getElementById("qmonths");
		var txtmon = emon.options[emon.selectedIndex].value;
		var nameProduct=document.getElementById("nameProduct").value;
		var type=document.getElementById("type").value;
		var statusPayment=document.getElementById("statusPayment").value;
		xmlhttp.open("GET","content_contract/or_search_invoice_tax_qui.php?loaitimkiem=qui&nam="+txtyear+"&qui="+txtmon+"&cusname="+encodeURIComponent(cusname)+"&nameProduct="+encodeURIComponent(nameProduct)+"&type="+type+"&statusPayment="+statusPayment,true);
		xmlhttp.send();
		
	}
	Load();
}
function sort_signDay(){
	var txtloaitimkiem=document.getElementById("loaitimkiem").value;
	//alert(txtloaitimkiem);
	var body = document.getElementById('showview');
	body.setAttribute('style','opacity:.5; position:relative;cursor: wait;  ');
	
	var d=document.createElement('div');
	d.setAttribute('style','display: block;visibility: visible; position: absolute;  z-index: 999; top: 0px; left: 0px; width: 105%; height: 105%; text-align: center;  filter: alpha(opacity=5); opacity: 0.5; ');
	
	var image=document.createElement('img');
	image.setAttribute('src','images/loading1.gif');
	image.setAttribute('style','position:absolute; left:0px; top:0px; right:0; bottom:0; margin:auto');
	
	d.appendChild(image);
	
    body.appendChild(d);
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("showview").innerHTML=xmlhttp.responseText;
										    	document.getElementById('showview').setAttribute('style','opacity:1; position:relative;');
										    	Load();
										  }
									  }
	if(txtloaitimkiem=="all"){
			xmlhttp.open("GET","content_contract/or_search_invoice_tax_month.php?loaitimkiem=all&action=sort_signDay",true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="ngay"){
		xmlhttp.open("GET","content_contract/or_search_invoice_tax.php?loaitimkiem=ngay&action=sort_signDay",true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="thang"){
		xmlhttp.open("GET","content_contract/or_search_invoice_tax_month.php?loaitimkiem=thang&action=sort_signDay",true);
		xmlhttp.send();
	}else if(txtloaitimkiem=="qui"){
		xmlhttp.open("GET","content_contract/or_search_invoice_tax_qui.php?loaitimkiem=qui&action=sort_signDay",true);
		xmlhttp.send();
		
	}
	Load();
}
function setdata(code,lang,company){
	
	document.getElementById("idcode").value=code;
	document.getElementById("lang").value=lang;
	document.getElementById("company").value=company;
	popup_window_show('#sample', { pos : 'window-center', width : '600px', height:'800px'});
	
}

function sendmail(){
    
	var id=document.getElementById("idcode").value;
	var lang=document.getElementById("lang").value;
	var company=document.getElementById("company").value;
	//alert(id+lang+company);
	
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
											  	//document.getElementById('showview').setAttribute('style','opacity:1; position:relative;');
										    	alert("Send mail successful");
										  }
									  }
	xmlhttp.open("GET","content_contract/sendmail_contract.php?code="+id+"&lang="+lang+"&company="+company,true);
	
	xmlhttp.send();
}
function rmReference1(str){ 
	if (str==""){
		document.getElementById("txtHint1").innerHTML="";
		return;
	} 
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/rmreference1.php?idemployee="+str,true);
	xmlhttp.send();
}
function showUser1(str){
	if (str==""){
		document.getElementById("txtHint").innerHTML="";
		return;
	} 
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/getuser1.php?q="+str,true);
	xmlhttp.send();
}
function showReference1(str){ 
	if (str==""){
		document.getElementById("txtHint1").innerHTML="";
		return;
	} 
	if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
		xmlhttp=new XMLHttpRequest();
	}else{// code for IE6, IE5
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.onreadystatechange=function(){
										  if (xmlhttp.readyState==4 && xmlhttp.status==200){
										    	document.getElementById("txtHint1").innerHTML=xmlhttp.responseText;
										  }
									  }
	xmlhttp.open("GET","ajax/getreference1.php?idemployee="+str,true);
	xmlhttp.send();
}
</script>
<style>
<!--
* {padding:0; margin:0;}
-->
</style>
<link rel="stylesheet" type="text/css" href="js/jquery.autocomplete.css" />
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<style type="text/css">
.content_menu_expand{
	position:absolute; 
	right:-5px;
	top:20px;
	z-index:999;
	background-color: #ffffff;
	-moz-border-radius: 7px;
	-webkit-border-radius: 7px;
	color: #000000;
	width:180px; 
	max-height:180px;
	overflow:auto;
}
.passul{padding-left:0; border:1px solid #111111}
.bgkhac {background: #eee;}
.passul ul{padding:0px}
.passul ul li {color:#474747; font-size:12px;padding: 5px 0;padding-left:5px;list-style: none;}
.passul ul li:hover { background: #0A246A;color:white;text-decoration: none;list-style: none;}
</style>
<link	href="css/style.css" rel="stylesheet" type="text/css" />
<div id="contains" style="background-color: #edf4f7;">
		 <input type="hidden" id="idcode" value=""/>
        <input type="hidden" id="lang" value=""/>
        <input type="hidden" id="company" value="" />
	<div class="title" style="padding-top: 5px;font-weight: bold;"><?php echo $l_accountant; ?>&rarr;<?php echo $l_contract; ?>&rarr;<?=$l_listcontract?></div>
	<div class="body" style="margin-left: 5px;margin-right:5px" id="contentEmpWorking">

		<div style="float: left; width: 150px; margin: 0px 5px 5px 0px;">
			<a href="contract.php?content=content_addcontract"><input id="addcontract" name="addcontract" value="<?=$l_addcontract?>" class="buttonNormal" style="width: 140px;background: #4f81bd;" type="submit" /></a>
			
		</div>
		<br style="clear: both" />
		<br style="clear: both" />
		<div style="width:100%" >
		<div style="width:100%" id="idtab">
		<table cellpadding="0" cellspacing="0" width="100%" border="1" class="atable" >		
		        	<tr>
		            	<td class="ffirst" style="text-align:left;height:24px;width:180px;"><span>*</span><?=$l_phanbiet?></td>
		                <td style="text-align:left;min-width: 255px;">
			                <label style="padding-left: 10px"><input type="radio" onclick="changeDistinction('ngay')" id="abc_ngay" name="abc" value="ngay"/><?=$l_theongay?></label>
			                <label style="padding-left: 10px"><input type="radio" onclick="changeDistinction('thang')" id="abc_thang" name="abc" value="thang"/><?=$l_theothang?></label>
			                <label style="padding-left: 10px"><input type="radio" onclick="changeDistinction('qui')" id="abc_qui" name="abc" value="qui"/><?=$l_theoqui?></label>
			                <label style="padding-left: 10px"><input type="radio" onclick="changeDistinction('all')" id="abc_all" name="abc" value="all" checked="checked"/><?=$l_all?></label>
		                </td>
		                <?php 
		              		if($_REQUEST["abc"]=="all"){
	                			?>
	                			<td class="ffirst" style="text-align:left"><span>*</span><?php echo $l_year;?></td>
	                			<td  style="text-align:left;">
	                				<div style="padding-left:9px;">
		                			<select onchange="changequi('tinhnam');" style="width:80px;height:22px;font-size:12px;" id="nam" name="nam" >
										<?php for($i=2012;$i<=($vyear+7);$i++){?>
											<option value="<?=$i?>"  
												<?php 
													if($i==$_REQUEST['nam']){
														?>
														selected="selected"
														<?php 
													}
												?>
											>
												<?php echo $i?>
											</option>
										<?php }?>
									</select>  
									<label style="padding-left: 10px"><input type="checkbox" name="checknam" id="checknam" value="<?=$_REQUEST['checknam']?>" onclick="donam()" />&nbsp;<?=$l_all?></label>
										
									</div>
	                			</td>
	                			<?php 
	                		}
		                
		                ?>
		            </tr>
		            <tr>
		            	
		            	<td class="ffirst" style="text-align:left;height: 24px;"><span></span><?=$l_signDay_contract?></td>
		                <td style="text-align:left" colspan='3'>
							<div id="showtime" style="padding-left:9px";>
								<input type="text" id="vttime" name="vttime" value="<?=$_REQUEST['vttime']?>" style="border:none;background:none;width:200px;font-size:12px;font-weight:bold;" readonly="readonly"/>
							</div>
						</td>

		                
		            </tr>
		        </table>
				</div>
		        <table cellpadding="0" cellspacing="0" border="1" class="atable" >		
		        	<tr>
		                <td class="ffirst" style="text-align:left;min-width:180px "><span></span><?=$l_type_contract?></td>
		                <td style="text-align:left;min-width: 265px">
		                	<select id="type" name="type" style="width:80px; height:24px;margin-left: 9px;" onkeypress="return enterTable(event,this.id,'0')">
		                					<option value="0"><?php echo $l_all;?></option>
	                                        <?php 
	                                        	if(mysql_num_rows($mangContractType)>0){
	                                        		while($row= mysql_fetch_array($mangContractType)){
	                                        			?>
	                                        			<option value="<?=$row["id"];?>"><?php echo $row["name".$lang];?></option>
	                                        			<?php 
	                                        			
	                                        		}
	                                        	}
	                                        ?>
	                                      </select>
		                </td>
		                
		                <td class="ffirst" style="text-align:left;min-width:180px "><span></span><?=$l_statusPayment_contract?></td>
		                <td style="text-align:left;min-width: 250px">
		                	<select id="statusPayment" name="statusPayment" style="width:80px; height:24px;margin-left: 9px;" onkeypress="return enterTable(event,this.id,'0')">
		                					<option value="-1"><?php echo $l_all;?></option>
		                					<option value="0"><?php echo $l_uncomplete;?></option>
		                					<option value="1"><?php echo $l_complete;?></option>
	                        </select>
		                </td>
		            </tr>
		            <tr>
		                <td class="ffirst" style="text-align:left;min-width:180px "><span></span><?=$l_company_name?></td>
		                <td style="text-align:left;min-width: 265px">
								<div style="float:left">
									<input type="text" size="30" name="nameCompany" id="nameCompany"   style="margin-left: 9px;width: 180px;height: 24px; border: 1px solid #c4c0c9;font-size: 12px;line-height: 24px;" autocomplete="off" />
									<div class="suggestionsBox" id="suggestions" style="display:none;">
										<img src="images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
										<div class="suggestionList" id="autoSuggestionsList">
											&nbsp;
										</div>
									</div> 						
								</div>
								<div style=" float:left; position:relative; margin-top: 5px; margin-left: -21px">
									<img alt="" src="images/arrow-down.png" id="menu_expand" >
								    <div id="content_menu_expand" class="passul content_menu_expand" style="display:none">
								        <ul>
								        <?php 
								        
								    		$sql="select name from contract_company";
											$result = mysql_query($sql);
											if($result)
											{
												$i=0;
												while($row=mysql_fetch_array($result))
												{
													?>
													<li onmouseover="this.style.cursor='pointer'"  onmouseout="this.style.cursor='default'" onclick="clickCustomer('<?=$row['name']?>')" 
														<?php 
															if($i%2!=0){
																?>
																class="bgkhac"
																<?php 
															}
														?>
													> <?php echo $row['name'];?></li>
													<?php 
													$i++;
												}
											}
								    	?>
								        </ul>
								    </div>
								</div>
							<div style="padding:5px;">
								<label style="padding-left: 10px"><input type="checkbox" name="checkkhung" id="checkkhung" value="<?=$_REQUEST['checkkhung']?>" onclick="dokhung()" />&nbsp;<?=$l_all?></label>
							</div>
		                </td>

		                <td class="ffirst" style="text-align:left;min-width:180px "><span></span><?=$l_nameProduct_contract?></td>
		                <td style="text-align:left;min-width: 265px">
								<div style="float:left">
									<input type="text" size="30" name="nameProduct" id="nameProduct"   style="margin-left: 9px;width: 180px;height: 24px; border: 1px solid #c4c0c9;font-size: 12px;line-height: 24px;" autocomplete="off" />
									<div class="suggestionsBox" id="suggestions" style="display:none;">
										<img src="images/upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
										<div class="suggestionList" id="autoSuggestionsList">
											&nbsp;
										</div>
									</div> 						
								</div>
								<div style=" float:left; position:relative; margin-top: 5px; margin-left: -21px">
									<img alt="" src="images/arrow-down.png" id="menu_expand6" >
								    <div id="content_menu_expand6" class="passul content_menu_expand" style="display:none">
								        <ul>
								        <?php 
								        
								    		$sql="select name from contract_nameProduct";
											$result = mysql_query($sql);
											if($result)
											{
												$i=0;
												while($row=mysql_fetch_array($result))
												{
													?>
													<li onmouseover="this.style.cursor='pointer'"  onmouseout="this.style.cursor='default'" onclick="clickCustomer6('<?=$row['name']?>')" 
														<?php 
															if($i%2!=0){
																?>
																class="bgkhac"
																<?php 
															}
														?>
													> <?php echo $row['name'];?></li>
													<?php 
													$i++;
												}
											}
								    	?>
								        </ul>
								    </div>
								</div>
							<div style="padding:5px;">
								<label style="padding-left: 10px"><input type="checkbox" name="checkkhung6" id="checkkhung6" value="<?=$_REQUEST['checkkhung']?>" onclick="dokhung6()" />&nbsp;<?=$l_all?></label>
							</div>
		                </td>
		            </tr>
		        </table>
		        </div>    
				<div style="text-align:center;">
	        	<input onclick="viewclick();" type="button" value="<?=$l_search?>" class="btnupbg btnupload" style="background: #4f81bd;width: 80px" />
	        </div>   
		<br style="clear: both" />
		<br style="clear: both" />
		<div id="showview" style="width:100%">
		<input type="hidden" id="loaitimkiem" value="all"/>
		<table id="listEmp" class="ftable" style="width: 100%;">

				<tr >
					<th  style="width: 30px;min-width: 30px" scope="col"><?=$l_no?></th>
					<!-- <th  style="width: 50px;min-width: 50px" scope="col"><?=$l_type_contract?></th> 
					<th  style="width: 90px;min-width: 90px" scope="col" ><?=$l_code_contract?></th>-->
					<th  style="min-width: 150px;" scope="col"><?=$l_name_contract?></th>
					<th  style="min-width: 90px;" scope="col"><a onclick="sort_signDay()"><?=$l_signDay_contract?></a></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_content_contract?></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_totalValue_contract?></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_prepaidMoney_contract?></th>
					<th  style="min-width: 90px;" scope="col"><?=$l_expectedDay_contract?></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_nameCompany_contract?></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_placeDelivery_contract?></th>
					<th  style="min-width: 80px;" scope="col"><?=$l_sendmail?></th>
				</tr>
				<?php $i =1;
				if(isset($_SESSION['listcontract']))
					unset($_SESSION['listcontract']);
				$listcontract=array();	
				$temp1="";
				$stong1=0;
				$stong2=0;
				$tong1=0;
				$tong2=0;
				if (mysql_num_rows($sqlempworking)>0){
				$row=mysql_fetch_array($sqlempworking);
				?>
					<tr>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $i;?></td>
					<!--  <td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['name'.$lang];?></td>
					<td  style="font-size: 12px;text-align: center;" scope="col"><a href="contract.php?content=content_editcontract&code=<?=$row['code']?>" ><?php echo $row['code'];?></a></td>-->
					<td  style="font-size: 12px;text-align: left;" scope="col" ><a href="contract.php?content=content_editcontract&code=<?=$row['code']?>" ><?php echo $row['name'];?></a></td>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['signDay'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['content'];?></td>
					<td  style="font-size: 12px;text-align: right;color: #111111;padding-right: 5px" scope="col"><span <?php if($row['statusPayment']==1) echo 'style="color: red"';?>><?php if($row['totalValue']!=0)echo number_format($row['totalValue']);?></span></td>
					<td  style="font-size: 12px;text-align: right;color: #111111;padding-right: 5px" scope="col"><?php if($row['prepaidMoney']!=0)echo number_format($row['prepaidMoney']);?></td>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['expectedDay'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['nameCompany'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['placeDelivery'];?></td>
					<td><img src="images/email.png"  onclick="setdata('<?=$row['code']?>','<?=$lang?>','<?=$temp[0]?>')" title="<?=$l_sendmail?>" /></td>
					</tr>
				<?php 
				$d=1;
				$tong1+=$row['totalValue'];
				$tong2+=$row['prepaidMoney'];
				$temp1=substr($row['signDay'], 0,7);
				$listcontract[$temp1][]=array($row['name'.$lang],$row['code'],$row['name'],$row['signDay'],$row['totalValue'],
				 									  $row['prepaidMoney'],$row['otherMoney'],$row['statusPayment'],$row['FullName'],$row['expectedDay'],$row['completeDay'],
				 									  $row['area'],$row['placeDelivery'],$row['nameCompany'], $row['agencies'],$row['provideGovernment'],$row['method1'],
				 									  $row['content'],$row['method2'],$row['provide'], $row['nameProduct'],$row['promotions'],$row['expireWarrantyDay'],
				 									  $row['agenciesCheck'],$row['methodsPayment'], $row['methodsDelivery'],$row['classification'],$row['comment']);
					while ($row=mysql_fetch_array($sqlempworking)){ 
				 	$i++ ;
				 	if($temp1!=substr($row['signDay'], 0,7)) {
						?>
					<tr class="coltr2" style="font-weight:bold;font-size:14px;">
		                <td colspan="2"  style="padding: 10px;color:#111111 ">
							<?php 
								$stong1+=$tong1;
								$stong2+=$tong2;
								if($_SESSION['loaitimkiem']=="thang"){
									?>
									<?php echo $l_month;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?> 
									<?php 
								}else if($_SESSION['loaitimkiem']=="qui"){
									?>
									<?php echo $l_quy;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?>
									<?php 
								}else if($_SESSION['loaitimkiem']=="all"){
									
									?>
									<?php echo $l_month;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?> 
									<?php 
								}
							?>
						</td>
		                <td style="text-align:right;"></td>
		                <td style="text-align:right;"></td>
		                <td style="text-align:right;padding-right: 5px;color:#111111 "><?php echo number_format($tong1);?></td>
		                <td style="text-align:right;padding-right: 5px;color:#111111 "><?php echo number_format($tong2);?></td>
		                <td></td>
		                <td></td>
		                <td></td>
		                <td></td>
		            </tr>
					<?php 
				 	$d=0;
				 	$temp1=substr($row['signDay'], 0,7);
				 	$tong1=0;
				 	$tong2=0;
				 	}?>
					<tr>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $i;?></td>
					<!--  <td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['name'.$lang];?></td>
					<td  style="font-size: 12px;text-align: center;" scope="col"><a href="contract.php?content=content_editcontract&code=<?=$row['code']?>" ><?php echo $row['code'];?></a></td>-->
					<td  style="font-size: 12px;text-align: left;" scope="col" ><a href="contract.php?content=content_editcontract&code=<?=$row['code']?>" ><?php echo $row['name'];?></a></td>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['signDay'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['content'];?></td>
					<td  style="font-size: 12px;text-align: right;color: #111111;padding-right: 5px" scope="col"><span <?php if($row['statusPayment']==1) echo 'style="color: red"';?>><?php if($row['totalValue']!=0)echo number_format($row['totalValue']);?></span></td>
					<td  style="font-size: 12px;text-align: right;color: #111111;padding-right: 5px" scope="col"><?php if($row['prepaidMoney']!=0)echo number_format($row['prepaidMoney']);?></td>
					<td  style="font-size: 12px;text-align: center;color: #111111;" scope="col"><?php echo $row['expectedDay'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['nameCompany'];?></td>
					<td  style="font-size: 12px;text-align: left;color: #111111;" scope="col"><?php echo $row['placeDelivery'];?></td>
					<td><img src="images/email.png"  onclick="setdata('<?=$row['code']?>','<?=$lang?>','<?=$temp[0]?>')" title="<?=$l_sendmail?>" /></td>
					</tr>
				<?php 
					$d++;
					$tong1+=$row['totalValue'];
					$tong2+=$row['prepaidMoney'];
					$listcontract[$temp1][]=array($row['name'.$lang],$row['code'],$row['name'],$row['signDay'],$row['totalValue'],
				 									  $row['prepaidMoney'],$row['otherMoney'],$row['statusPayment'],$row['FullName'],$row['expectedDay'],$row['completeDay'],
				 									  $row['area'],$row['placeDelivery'],$row['nameCompany'], $row['agencies'],$row['provideGovernment'],$row['method1'],
				 									  $row['content'],$row['method2'],$row['provide'], $row['nameProduct'],$row['promotions'],$row['expireWarrantyDay'],
				 									  $row['agenciesCheck'],$row['methodsPayment'], $row['methodsDelivery'],$row['classification'],$row['comment']);	
					
					}
				$_SESSION['listcontract']=$listcontract;
				?>
				<tr class="coltr2" style="font-weight:bold;font-size:14px;">
		                <td colspan="2"  style="padding: 10px;color:#111111 ">
							<?php 
							$stong1+=$tong1;
							$stong2+=$tong2;
								if($_SESSION['loaitimkiem']=="thang"){
									?>
									<?php echo $l_month;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?> 
									<?php 
								}else if($_SESSION['loaitimkiem']=="qui"){
									?>
									<?php echo $l_quy;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?>
									<?php 
								}else if($_SESSION['loaitimkiem']=="all"){
									
									?>
									<?php echo $l_month;?> : <font color="red"><?php echo substr($temp1, 0,7); ?></font>  -  <?php echo $l_co;?>  <font color="blue"><?php echo number_format($d);?></font> <?php echo $l_contract;?> 
									<?php 
								}
							?>
						</td>
		                
		                <td style="text-align:right;"></td>
		                <td style="text-align:right;"></td>
		                <td style="text-align:right;padding-right: 5px;color:#111111"><?php echo number_format($tong1);?></td>
		                <td style="text-align:right;padding-right: 5px;color:#111111"><?php echo number_format($tong2);?></td>
		                <td></td>
		                <td></td>
		                <td></td>
		                <td></td>
		            </tr>
		            <tr style="font-weight:bold;font-size:15px;color:green;">
				        <td colspan="4" style="padding: 10px;"><?php echo $l_tongdon?></td>
		                
		                <td style="text-align:right;padding-right: 5px;color:#111111"><?php echo number_format($stong1);?></td>
		                <td style="text-align:right;padding-right: 5px;color:#111111"><?php echo number_format($stong2);?></td>
		                <td></td>
		                <td></td>
		                <td></td>
		                <td></td>
		            </tr>
				<?php }
				else{
				?>
				<tr>
				<td colspan="9"><?=$l_list_emplty?></td>
				</tr>
				<?php }?>
		</table>
		<?php 
        		if($soluong>0){
        			?>
        			<div class="fbox2" style="text-align:center; width:100%;">
        				<a href="printer/export_contract.php?typeSearch=all&type=0&statusPayment=-1&cusname=&nameProduct=&vtime=~"><input type="button" value="<?=$l_export_excel?>" class="btnupbg btnupload" style="background: #4f81bd;"/></a>
        			</div>
        			<?php	
        		}
        		?>
		</div>
			
	</div>
</div>

